home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
bc_ti.zip
/
TI801.ASC
< prev
next >
Wrap
Text File
|
1992-02-25
|
1KB
|
67 lines
PRODUCT : C++ NUMBER : 801
VERSION : All
OS : DOS
DATE : February 25, 1992 PAGE : 1/1
TITLE : Defining and Using Arrays of Pointers to Functions
The following demonstrates how to define and initailize an array
of pointers to functions. In addition, calling a function whose
pointer is contained in such an array is demonstrated.
#include <stdio.h>
void (*p[5])(); // p is defined to be an array of
// 5 pointers to functions taking
// no (void) paramaters and returning
// nothing (void)
void foo1(void) { printf("Hello, in function foo1\n"); }
void foo2(void) { printf("Hello, in function foo2\n"); }
main()
{
p[0]=foo1; // Assign pointer at array index 0
// to point at function foo1.
p[0](); // Now call foo1
p[1]=foo2; // Assign pointer at array index 1
// to point to function foo2.
p[1](); // Now call foo2
}